package com.ctshk.rpc.system.dto;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @author 谢诗宏
 * @description
 * @date 2020/12/15
 */
@Data
@ApiModel
@Accessors(chain = true)
public class UserDTO implements Serializable {

    private static final long serialVersionUID = -4911662568485174533L;

    @ApiModelProperty(name = "id", value = "id")
    private Long id;
    @ApiModelProperty(name = "username", value = "账号")
    private String username;
    @ApiModelProperty(name = "title", value = "中文名(用于在树形菜单中前端使用)")
    private String title;
    @ApiModelProperty(name = "fullName", value = "中文名")
    private String fullName;
    @ApiModelProperty(name = "englishName", value = "英文名")
    private String englishName;
    @ApiModelProperty(name = "createDept", value = "用户名称和部门")
    private String createDept;

    @ApiModelProperty(value = "中文姓")
    private String cnSurname;
    @ApiModelProperty(value = "中文名")
    private String cnName;
    @ApiModelProperty(value = "英文姓")
    private String enSurname;
    @ApiModelProperty(value = "英文名")
    private String enName;

    @JsonIgnore
    @ApiModelProperty(name = "password", value = "密码")
    private String password;
    @ApiModelProperty(name = "avatar", value = "头像")
    private String avatar;
    @ApiModelProperty(name = "menuIds", value = "当前账号的菜单ids数组")
    private List<Object> menuIds;
    @ApiModelProperty(name = "menuIds", value = "当前账号的按钮ids数组,应前端需要定义此结构")
    private Map<Object, List> buttonIds;

    @ApiModelProperty(value = "性别")
    private Integer gender;
    @ApiModelProperty(value = "员工号")
    private String employeeNumber;
    @ApiModelProperty(name = "deptId", value = "部门id")
    private Long deptId;
    @ApiModelProperty(name = "dept", value = "部门")
    private String dept;
    @ApiModelProperty(name = "deptCode", value = "部门编码")
    private String deptCode;
    @ApiModelProperty(name = "deptNumber", value = "部门编号")
    private String deptNumber;
    @ApiModelProperty(name = "deptCostCode", value = "部门成本中心编码")
    private String deptCostCode;
    @ApiModelProperty(name = "roles", value = "角色id,多个逗号分隔")
    private String roles;
    @ApiModelProperty(value = "角色名称，用逗号隔开")
    private String roleName;
    @ApiModelProperty(name = "position", value = "职位")
    private String position;
    @ApiModelProperty(name = "positionName", value = "职位Name")
    private String positionName;
    @ApiModelProperty(name = "mobile", value = "电话号码")
    private String mobile;
    @ApiModelProperty(name = "mobileAreaCode", value = "电话号码区号")
    private String mobileAreaCode;
    @ApiModelProperty(value = "其他电话")
    private String mobileOther;
    @ApiModelProperty(value = "其他电话区号")
    private String mobileOtherAreaCode;
    @ApiModelProperty(value = "座机号")
    private String telephone;
    @ApiModelProperty(value = "座机号区号")
    private String telephoneAreaCode;
    @ApiModelProperty(value = "传真")
    private String fax;
    @ApiModelProperty(value = "传真区号")
    private String faxAreaCode;
    @ApiModelProperty(name = "email", value = "邮箱")
    private String email;
    @ApiModelProperty(name = "status", value = "用户状态（0禁用 1正常）")
    private Integer status;
    @ApiModelProperty(value = "锁定状态态（false:正常;true:锁定）")
    private Boolean locked;

    public String getFullName() {
        return StrUtil.concat(true, getCnSurname(), getCnName());
    }

    public String getEnglishName() {
        return StrUtil.concat(true, getEnName(), getEnSurname());
    }

    public String getTitle() {
        return StrUtil.concat(true, getCnSurname(), getCnName());
    }

    public String getCreateDept() {
        String fullName = getFullName() == null ? "" : getFullName();
        String dept = getDept() == null ? "" : getDept();
        if (StringUtils.isBlank(fullName) && StringUtils.isBlank(dept)) {
            return "";
        }
        return fullName.concat("/" + dept);
    }
}
